package services

import (
	"context"
	"go.didapinche.com/foundation/plat-echo/app/ops/models"
	"go.didapinche.com/foundation/plat-echo/app/ops/repositories"
	"go.didapinche.com/time"
)

type DingDingService interface {
	Find(ctx context.Context, info *models.DingDing) ([]*models.DingDing, int64, error)
	DeleteByID(ctx context.Context, id uint64) error
	Update(ctx context.Context, info *models.DingDing) (*models.DingDing, error)
	Create(ctx context.Context, info *models.DingDing) (*models.DingDing, error)
}

type dingDingService struct {
	dingDingRepo repositories.DingdingRepository
}

func NewDingDingService(dingDingRepo repositories.DingdingRepository) DingDingService {
	return &dingDingService{
		dingDingRepo: dingDingRepo,
	}
}

func (d dingDingService) Find(ctx context.Context, info *models.DingDing) ([]*models.DingDing, int64, error) {
	return d.dingDingRepo.Find(ctx, info)
}

func (d dingDingService) DeleteByID(ctx context.Context, id uint64) error {
	return d.dingDingRepo.DeleteByID(ctx, id)
}

func (d dingDingService) Update(ctx context.Context, info *models.DingDing) (*models.DingDing, error) {
	return d.dingDingRepo.Update(ctx, info)
}

func (d dingDingService) Create(ctx context.Context, info *models.DingDing) (*models.DingDing, error) {
	info.CreateTime = time.Now()
	return d.dingDingRepo.Create(ctx, info)
}
